<!doctype html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <title>个人信息</title>
    <div th:insert="user/common::head"></div>
</head>

<body class="">
<div class="wrapper ">
    <div th:insert="~{user/common::sidebar(active='dashboard.html')}"></div>
    <div class="main-panel">
        <!-- Navbar导航栏 -->
        <nav th:replace="~{user/common::navbar}"></nav>
        <div class="panel-header">
            <form id="search_form" th:action="@{/patient/search}">
                <div class="header text-center">
                    <h2 class="title">员工个人信息</h2>
                </div>
            </form>
        </div>
        <div class="content">
            <div class="row">
                <div class="col-md-8 offset-2">
                    <div class="card">
                        <div class="card-body">
                            <form id="update_form" method="post">
                                <div class="row">
                                    <div class="col-md-6 offset-3">
                                        <div class="form-group">
                                            <label>员工ID</label>
                                            <input name="staffId" type="text" class="form-control" th:value="${staff.getStaffId()}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-6 offset-3">
                                        <div class="form-group">
                                            <label>用户名</label>
                                            <input name="staffUsername" type="text" class="form-control" th:value="${staff.getStaffUsername()}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-6 offset-3">
                                        <div class="form-group">
                                            <label>员工姓名</label>
                                            <input name="staffName" type="text" class="form-control" placeholder="请输入员工的姓名" th:value="${staff.getStaffName()}">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-6 offset-3">
                                        <div class="form-group">
                                            <label>联系方式</label>
                                            <input name="staffPhone" type="number" class="form-control" placeholder="员工的手机号" th:value="${staff.getStaffPhone()}">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-6 offset-3">
                                        <div class="form-group">
                                            <label>员工年龄</label>
                                            <input name="staffAge" type="number" class="form-control" placeholder="员工年龄" th:value="${staff.getStaffAge()}">
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-6 offset-3">
                                        <div class="form-group">
                                            <label>创建时间</label>
                                            <input name="createTime" type="date" class="form-control" placeholder="Home Address" onclick="getDate()" min="" th:value="${#dates.format(staff.getCreateTime(),'yyyy-MM-dd')}" readonly>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-8 offset-3">
                                       <a class="btn-warning btn btn-lg col-4 text-white" th:href="@{/toDashBoard}">返回</a>
                                        <input type="button" onclick="updateInfo()" class="btn-primary btn btn-lg col-4" value="修改">
                                    </div>
                                </div>
                                <input type="text" name="staffPassword" th:value="${staff.getStaffPassword()}" hidden="hidden">
                                <input type="text" name="createTime" th:value="${staff.getCreateTime()}" hidden="hidden">
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <!--底部footer-->
        <footer th:replace="~{user/common::footer}"></footer>
    </div>
</div>
<!--通用footerJs-->
<script th:replace="~{user/common::footerJs}"></script>
</body>

<script>
    function updateInfo(){
        var formData = $("#update_form").serialize();
        $.ajax({
            sync:false,
            url:'/staff/update',
            data: formData,
            method:'post',
            dataType:'text',
            success:function(result){
                if(result==='修改成功!'){
                    demo.showNotification('success',result);
                    setTimeout(function (){
                        window.location = '/toStaffInfo'
                    },1000)
                    return;
                }
                demo.showNotification('danger',result);
            }
        })
    }
</script>
</html>
